// 接口的合并
// interface UserInter{
//     name: string;
// }
// interface UserInter{
//     age: number;
// }

interface AgeInter{
    age: number;
}

interface UserInter extends AgeInter{
    name: string;
}

const user:UserInter = {
    name: "后盾人",
    age:18
}
console.log(user);

// type的合并
type Name = {
    name:string
};

type Age = {
    age:number
}

// &表示两个都满足，|表示满足其一
type usertype1 = Name & Age;
type usertype2 = Name | Age;
const u1:usertype1 = {
    name: "后盾人",
    age:20
};
const u2:usertype2 = {
    age:22
};
console.log(u1);
console.log(u2);



// type也可以用于类的实现
type usertype3 = {name:string;age:number;};
class Person implements usertype3 {
    name:string = "hdms"
    age:number = 11
    show():string{
        return `${this.name}的年龄是${this.age}`;
    }
}

const person = new Person();
console.log(person.show());




// type和interface可以一起使用
type Member1 = {
    name : string
};

interface Member2 {
    age : number
}

// 也可以用|
type Member3 = Member1 & Member2;
const mm:Member3 = {
    name: "后盾人",
    age:33
};
console.log(mm);

